Display Number of Characters in Object Text

I"ve played around with a script to display in a DXL Layout column the count of the number of characters in the Object Text of an object. I've tried tweaking it several different ways, but keep coming up with error messages along the lines of "incorrect use of the function "stringOf". Here's my broken code:
 

Object o = current
Buffer textBuffer = create
int iBuffLength = 0
 
textBuffer = richTextNoOle o."Object Text"
iBuffLength = length(textBuffer)
string s = stringOf (iBuffLength)
displayRich s ""

 


I just know I'm overlooking something stupid, but I can't figure it out...
Chris Annal
SW Test Engineer / DOORS Database Administrator
Sensis Corporation, East Syracuse, New York
chrisa@sensis.com

 


ChrisAnnal - Thu Jul 14 14:15:25 EDT 2011

Re: Display Number of Characters in Object Text
OurGuest - Thu Jul 14 14:27:10 EDT 2011

I suspect what you are wanting is: display iBuffLength ""

Re: Display Number of Characters in Object Text
ChrisAnnal - Thu Jul 14 14:51:02 EDT 2011

OurGuest - Thu Jul 14 14:27:10 EDT 2011
I suspect what you are wanting is: display iBuffLength ""

D-OOooh. That did the trick, thanks!!
P.S. (I also left out the line where I delete the buffer at the end).

Chris Annal
SW Test Engineer / DOORS Database Administrator
Sensis Corporation, East Syracuse, New York
chrisa@sensis.com

Re: Display Number of Characters in Object Text
llandale - Thu Jul 14 14:57:59 EDT 2011

There is no such function "string stringOf(int)".
You convert an integer to a string by concatenating a string onto the end of it.

Object o = current
Buffer textBuffer = create
int iBuffLength = 0
 
textBuffer = richTextNoOle o."Object Text"
iBuffLength = length(textBuffer)
string s = iBuffLength ""   // << change here
displayRich s
delete(textBuffer)          //<< don't forget this


> do not use the 'current' object; that's the one you have selected, not the one for which the Layout is executing. Use pre-defined pre-populated "obj" variable for layouts and attrDXL.
> The results are not Rich so you can just 'display' them.
>It seems likely you 'want' to count the number of characters in the raw text; who really cares about those invisible rich-text-markup characters. Don't need the Buffer

 

string Text = obj."Object Text"
display "Text length: " (length(Text)) ""

 

 

  • Louie

 

Re: Display Number of Characters in Object Text
ChrisAnnal - Thu Jul 14 15:16:04 EDT 2011

llandale - Thu Jul 14 14:57:59 EDT 2011

There is no such function "string stringOf(int)".
You convert an integer to a string by concatenating a string onto the end of it.

Object o = current
Buffer textBuffer = create
int iBuffLength = 0
 
textBuffer = richTextNoOle o."Object Text"
iBuffLength = length(textBuffer)
string s = iBuffLength ""   // << change here
displayRich s
delete(textBuffer)          //<< don't forget this


> do not use the 'current' object; that's the one you have selected, not the one for which the Layout is executing. Use pre-defined pre-populated "obj" variable for layouts and attrDXL.
> The results are not Rich so you can just 'display' them.
>It seems likely you 'want' to count the number of characters in the raw text; who really cares about those invisible rich-text-markup characters. Don't need the Buffer

 

string Text = obj."Object Text"
display "Text length: " (length(Text)) ""

 

 

  • Louie

 

You're right, Louie. Your solution is best. I didn't need all those invisible rich-text-markup characters. Those two lines were all I really needed, thanks!!

Chris Annal
SW Test Engineer / DOORS Database Administrator
Sensis Corporation,
East Syracuse, New York
chrisa@sensis.com